home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 223_01 / atoi.c < prev    next >
Text File  |  1980-01-01  |  512b  |  18 lines

  1. #define NOCCARGC  /* no argument count passing */
  2. /*
  3. ** atoi(s) - convert s to integer.
  4. */
  5.   static int sign, n;
  6.  
  7. atoi(s) char *s; {
  8.   while(isspace(*s)) ++s;
  9.   sign = 1;
  10.   switch(*s) {
  11.     case '-': sign = -1;
  12.     case '+': ++s;
  13.     }
  14.   n = 0;
  15.   while(isdigit(*s)) n = 10 * n + *s++ - '0';
  16.   return (sign * n);
  17.   }
  18.